<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    	<title>统战成员学习平台</title>
	    <link rel="stylesheet" type="text/css" href="../../css/base.css" />
	    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
	</head>
	<body class="white">
		<div id='app' style="display:none" v-show="true" class="main_bg">
			<div class="exam_start">
				<div class="exam_info">
					<p class="ui_border_b">{{name}}</p>
					<ul class="ui_border_b">
						<li class="ui_border_b">试题数量：{{detail.exmList.length}}</li>
						<li class="ui_border_b">考试时间：{{detail.examTime}}min</li>
						<li class="ui_border_b">考试总分：{{detail.fullmarks}}分</li>
						<li>合格分数：{{detail.qualifiedScore}}分</li>
					</ul>
				</div>
				<div @click="exam()" tapmode="tap" class="big_btn yellow">开始考试</div>
				<p class="exam_last">剩余次数：{{detail.surplusExamNum === -1 ? '不限次数' : detail.surplusExamNum}}</p>
			</div>
		</div>
		<script type="text/javascript" src="../../script/api.js"></script>
		<script type="text/javascript" src="../../script/vue.min.js"></script>
		<script type="text/javascript" src="../../script/common.js"></script>
		<script type="text/javascript" src="../../script/layer_mobile/layer.js"></script>
		<script type="text/javascript">
		    new Vue({
				el: '#app',
		     	data: {
					courseId: 0,
					scheduleId: 0,
					leaningGroupsId: 0,
					catalogId: 0,
					type: 0,
					name: '',
					detail: {exmList: []}
		     	},
				mounted: function() {
		        	var $this = this;
		        	apiready = function() {
						api.parseTapmode();
						$this.courseId = api.pageParam.courseId;
						$this.scheduleId = api.pageParam.scheduleId;
						$this.leaningGroupsId = api.pageParam.leaningGroupsId;
						$this.catalogId = api.pageParam.catalogId;
						$this.type = api.pageParam.type;
						$this.name = api.pageParam.name;
						$this.init();
						api.addEventListener({
						    name: 're_exam_event'
						}, function(ret, err){
						    $this.init();
						});
                	}
		    	},
		    	methods: {
					init: function() {
						var $this = this;
						post('/client/exam/creatRandomPaper', {
							courseId: $this.courseId,
							scheduleId: $this.scheduleId,
							leaningGroupsId: $this.leaningGroupsId,
							catalogId: $this.catalogId,
							type: $this.type
						}, function(ret) {
							if(ret.isSuccess) {
								$this.detail = ret.data;
								$api.setStorage(_.EXAMLIST, ret.data);
							} else {
								api.alert({
								    title: '提示',
								    msg: ret.message
								}, function(ret, err){
								    if(ret){
								         closeWin()
								    }
								});
							}
						})
					},
					exam: function() {
						var $this = this;
						if($this.detail.exmList.length > 0) {
							openWin('exam_win', {
								examTime: $this.detail.examTime,
								courseId: $this.courseId,
								leaningGroupsId: $this.leaningGroupsId,
								scheduleId: $this.scheduleId,
								type: $this.type,
								name: $this.name
							})
						}
					}
		    	}
		    });
		</script>
	</body>
</html>
